/* import { app } from 'electron'
import { DataSource } from 'typeorm'
import { User } from '../entity/User'
import { Comment } from '../entity/Comment'
import { Category } from '../entity/Category'
import { Project } from '../entity/Project'
import { InventoryDetails } from '../entity/InventoryDetails'
import { join } from 'path'
import bsmc3 from 'better-sqlite3-multiple-ciphers'
import SnakeCaseNamingStrategy from './NamingStrategy'
// import { Database } from 'better-sqlite3-multiple-ciphers';
// import path from "path"
// import { fileURLToPath } from "url"
// const __filename = fileURLToPath(import.meta.url)
// const __dirname = path.dirname(__filename)
// console.log(__filename, '__filename')
// console.log(__dirname, '__dirname')
console.log('process.env.NODE_ENV = ', process.env.NODE_ENV)
const isProd = process.env.NODE_ENV !== 'development'
const basePath = `./db/warehouse.db`
const dataBasePath = join(app.getPath('appData'), app.getName(), basePath)
const dbPath = isProd ? dataBasePath : basePath
console.log('dataBasePath = ', dataBasePath)
console.log('dbPath === ', dbPath)
const entities = [User, Comment, Category, Project, InventoryDetails]
export const AppDataSource = new DataSource({
  type: 'better-sqlite3',
  database: dbPath,
  synchronize: true,
  logging: false,
  entities: entities,
  migrations: entities,
  subscribers: [],
  driver: bsmc3,
  namingStrategy: new SnakeCaseNamingStrategy(),
  prepareDatabase: (db) => {
    db.pragma(`cipher='sqlcipher'`)
    db.pragma(`legacy=4`) // sqlcipher 版本
    db.pragma(`key=sj123456`) // 密码
  }
  // entities: [__dirname + "/entity/*.ts" ],
  // nativeBinding: 'better-sqlite3/'//betterSqlite3Path // betterSqlite3Path, // join(__dirname, "./better_sqlite3.node")
})
 */
